/**
 * 这一课执行一个非常帅气自定义错误的处理方法
 */
{
	const ErrorDecorator: MethodDecorator = (
		target: Object,
		propertyKey: string | symbol,
		descriptor: PropertyDescriptor
	) => {
		let method = descriptor.value
		descriptor.value = () => {
			try {
				method()
			} catch (error: any) {
				console.log(
					`%cJimmy will still love Xuexue`,
					'color:#e67e22;font-size:30px'
				)
				console.log(`%c${error.message}`, 'color:red;font-size:16px')
			}
		}
	}

	class User {
		@ErrorDecorator
		public find() {
			throw new Error('查找用户失败')
		}
	}

	new User().find()
}
